<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */

$this->title = Yii::t('app', '编辑文章');
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', '文章列表'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
$config = \common\components\Config::getQiNiuConfig();
$this->registerJs('
window.saveto =\'qiniu\';   //储存位置为七牛云，对应于插件里的判断值
window.qiniu_uptoken=\''.$config['token'].'\';  //七牛云服务端生成的uptoken
window.qiniu_upload_domain=\'http://upload.qiniu.com\';   //七牛云上传地址，一般无需修改，https需要修改成对应的七牛云https上传域名
window.qiniu_bucket_domain=\''.$config['domain'].'\';   //七牛云bucket设置的域名
');
$this->registerJsFile('/public/js/modules/plupload/plupload.full.min.js');
$this->registerJsFile('/public/js/modules/qiniu.min.js');
$this->registerJsFile('/public/js/modules/ckeditor/4.8.0.full/ckeditor.js');
?>
<div class="category-index">
    <section class="panel panel-default">
        <header class="panel-heading font-bold">文章信息</header>
        <div class="panel-body">
            <form class="form-horizontal ajax-submit" method="post">
                <div class="form-group">
                    <label class="col-sm-1 control-label">标题</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="Article[title]" value="<?= \yii\helpers\ArrayHelper::getValue($info, 'title')?>">
                        <span class="help-block m-b-none"></span><!--注释表单-->
                    </div>
                    <label class="col-sm-1 control-label">分类</label>
                    <div class="col-sm-5">
                        <select name="Article[cat_id]" class="form-control m-b">
                            <?php foreach($category as $item):?>
                                <option
                                        value="<?= \yii\helpers\ArrayHelper::getValue($item, 'cat_id')?>"
                                    <?= isset($info['cat_id']) && $info['cat_id'] == $item['cat_id'] ? 'selected': '';?>
                                >
                                    <?= \yii\helpers\ArrayHelper::getValue($item, 'html')?>
                                </option>
                            <?php endforeach;?>
                        </select>
                    </div>
                </div>
                <div class="line line-dashed line-lg pull-in"></div>

                <div class="form-group">

                    <label class="col-sm-1 control-label">关键词</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="Article[keywords]" value="<?= \yii\helpers\ArrayHelper::getValue($info, 'keywords')?>">
                        <span class="help-block m-b-none"></span><!--注释表单-->
                    </div>
                    <label class="col-sm-1 control-label">排序</label>
                    <div class="col-sm-2">
                        <input type="text" class="form-control" name="Article[sort]" value="<?= \yii\helpers\ArrayHelper::getValue($info, 'sort')?>">
                        <span class="help-block m-b-none"></span><!--注释表单-->
                    </div>
                </div>
                <div class="line line-dashed line-lg pull-in"></div>

                <div class="form-group">
                    <label class="col-sm-1 control-label">描述</label>
                    <div class="col-sm-5">
                        <textarea class="form-control" name="Article[description]"><?= \yii\helpers\ArrayHelper::getValue($info, 'description')?></textarea>
                        <span class="help-block m-b-none"></span><!--注释表单-->
                    </div>

                    <label class="col-sm-1 control-label">缩略图</label>
                    <div class="col-sm-5">
                        <div class="row">
                            <div class="col-sm-5">
                                <div  style="width:200px;height:150px;background:#c2ccd1;display:inline-block;">
                                    <img src="<?= \yii\helpers\ArrayHelper::getValue($info, 'thumb')?>" class="img-center image-preview">
                                </div>
                            </div>
                            <div class="col-sm-5">
                                <button type="button" class="btn btn-success btn-thumb-upload">上传</button>
                                <button type="button" class="btn btn-info btn-thumb-cut">裁剪</button>
                                <button type="button" class="btn btn-danger btn-thumb-del">删除</button>
                            </div>
                        </div>



                        <input type="hidden" class="form-control" name="Article[thumb]" value="<?= \yii\helpers\ArrayHelper::getValue($info, 'thumb')?>">
                        <span class="help-block m-b-none"></span><!--注释表单-->
                    </div>
                </div>
                <div class="line line-dashed line-lg pull-in"></div>

                <div class="form-group">
                    <label class="col-sm-1 control-label">内容</label>
                    <div class="col-sm-10">
                        <textarea id="editor" name="Article[content]"><?= htmlentities(\yii\helpers\ArrayHelper::getValue($info, 'content'));?></textarea>
                    </div>
                </div>
                <div class="line line-dashed line-lg pull-in"></div>

                <div class="form-group">
                    <div class="col-sm-4 col-sm-offset-2">
                        <button type="button" class="btn btn-default">取消</button>
                        <button type="submit" class="btn btn-primary">保存</button>
                    </div>
                </div>
                <input type="hidden" name="Article[art_id]" value="<?= \yii\helpers\ArrayHelper::getValue($info, 'art_id')?>">
                <input type="hidden" value="<?php echo Yii::$app->request->csrfToken; ?>" name="<?= Yii::$app->request->csrfParam?>" >
            </form>
        </div>
    </section>


</div>
